<template>
  <div style="width: 400px; padding-top: 10px">
    <span style="font-size:18px">请选择年份：</span>
    <el-date-picker
      v-model="year"
      type="year"
      size="small"
      style="width: 130px; margin-right: 5px"
      placeholder="选择年份"
    >
    </el-date-picker>
    <el-button @click="getDocx" size="small" type="primary"
      >导出就业质量报告</el-button
    >
  </div>
</template>

<script>
import jszip from 'jszip'
import JSZipUtils from 'jszip-utils'
import docxtemplater from 'docxtemplater'
import FileSaver from 'file-saver'
import { getYears, getBasicData, getDirectionData, getSchoolData, getOrgKindData, getOrgLocationData, getOrgIndustryData, getOrgNameData } from '@/api/docx'

export default {
  name: 'exportDocx',
  data() {
    return {
      years: [],
      maxYear: null,
      minYear: null,
      year: null,
      total: null,
      bachelorNum: null,
      masterNum: null,
      employment: {
        study: {
          domestic: {//国内升学
            bachelor: {
              num: null,
              rate: ''
            },
            master: {
              num: null,
              rate: ''
            }
          },
          aboard: {//境外升学
            bachelor: {
              num: null,
              rate: ''
            },
            master: {
              num: null,
              rate: ''
            }
          },
        },
        work: {
          fomalWork: {
            bachelor: {
              num: 0,
              rate: ''
            },
            master: {
              num: 0,
              rate: ''
            }
          },
          otherWork: {
            bachelor: {
              num: 0,
              rate: ''
            },
            master: {
              num: 0,
              rate: ''
            }
          }
        }
      },
      unemployment: {
        bachelor: {
          num: 0,
          rate: ''
        },
        master: {
          num: 0,
          rate: ''
        }
      },
      form: {
        year: 2020,
        currentYear: new Date().getFullYear(),
        currentMonth: new Date().getMonth() + 1,
        currentDate: new Date().getDate(),
        total: null,
        maleNum: null,
        femaleNum: null,
        bachelorNum: null,
        masterNum: null,
        backToOriginRate: '',
        BSNum: null,
        BSRate: '',
        MSNum: null,
        MSRate: '',
        SNum: null,
        SRate: '',
        BDSNum: null,
        BDSRate: '',
        MDSNum: null,
        MDSRate: '',
        SDNum: null,
        SDRate: '',
        BASNum: null,
        BASRate: '',
        MASNum: null,
        MASRate: '',
        ASNum: null,
        ASRate: '',
        BJNum: null,
        BJRate: '',
        MJNum: null,
        MJRate: '',
        JNum: null,
        JRate: '',
        BFJNum: null,
        BFJRate: '',
        MFJNum: null,
        MFJRate: '',
        FJNum: null,
        FJRate: '',
        BOJNum: null,
        BOJRate: '',
        MOJNum: null,
        MOJRate: '',
        OJNum: null,
        OJRate: '',
        BNNum: null,
        BNRate: '',
        MNNum: null,
        MNRate: '',
        NNum: null,
        NRate: '',
        BTNum: null,
        BTRate: '',
        MTNum: null,
        MTRate: '',
        TNum: null,
        TRate: '',
        bacEmpRate: '',
        masEmpRate: '',
        empRate: '',
        industry: [],
        industryMaxName: '',
        industry2: '',
        industry3: '',
        industry4: '',
        industry5: '',
        industryMaxRate: '',
        org: [],
        ds1: '',
        ds1n: null,
        ds1r: '',
        ds2: '',
        ds2n: null,
        ds3: '',
        ds3n: null,
        ds4: '',
        ds4n: null,
        ds5: '',
        ds5n: null,
        ds6: '',
        ds6n: null,
        as1: '',
        as1n: null,
        as1r: '',
        as2: '',
        as2n: null,
        as3: '',
        as3n: null,
        as4: '',
        as4n: null,
        dzbn: '',
        dzbr: '',
        dzmn: '',
        dzmr: '',
        dzn: '',
        dzr: '',
        sy1bn: '',
        sy1br: '',
        sy1mn: '',
        sy1mr: '',
        sy1n: '',
        sy1r: '',
        sy2bn: '',
        sy2br: '',
        sy2mn: '',
        sy2mr: '',
        sy2n: '',
        sy2r: '',
        sy3bn: '',
        sy3br: '',
        sy3mn: '',
        sy3mr: '',
        sy3n: '',
        sy3r: '',
        sy4bn: '',
        sy4br: '',
        sy4mn: '',
        sy4mr: '',
        sy4n: '',
        sy4r: '',
        qy1bn: '',
        qy1br: '',
        qy1mn: '',
        qy1mr: '',
        qy1n: '',
        qy1r: '',
        qy2bn: '',
        qy2br: '',
        qy2mn: '',
        qy2mr: '',
        qy2n: '',
        qy2r: '',
        qy3bn: '',
        qy3br: '',
        qy3mn: '',
        qy3mr: '',
        qy3n: '',
        qy3r: '',
        bdbn: '',
        bdbr: '',
        bdmn: '',
        bdmr: '',
        bdn: '',
        bdr: '',
        syb: null,
        sybr: null,
        sym: null,
        symr: null,
        sy: null,
        syr: null,
        qyb: null,
        qybr: null,
        qym: null,
        qymr: null,
        qy: null,
        qyr: null,
      }

    }
  },
  created() {
    //获取年份列表
    getYears().then(res => {
      this.years = res.data

      this.years = this.years.sort(function (a, b) {
        return a - b;
      })

      //默认为最近一年

      this.minYear = new Date('' + this.years[0] + '-1-1')
      this.maxYear = new Date('' + this.years[this.years.length - 1] + '-1-1')
      this.year = new Date('' + this.years[this.years.length - 1] + '-1-1')
    }).catch(err=>{
        console.log(err)
    })

    //获取基础信息
    // this.doBasicData()

  },
  methods: {
    getDocx() {
      console.log(this.year)
      //判断year是否有效
      if (!this.year.getFullYear()) {
        this.$message({
          type: 'error',
          message: '请选择年份'
        })
      } else if (this.year.getFullYear() == 2015) {
        this.$message({
          type: 'error',
          message: '2015年没有研究生数据，无法导出'
        })
      } else if (this.year.getFullYear() < this.years[0] || this.year.getFullYear() > this.years[this.years.length - 1]) {
        this.$message({
          type: 'error',
          message: '年份超出范围，无法导出'
        })
      } else {
        this.form.year = this.year.getFullYear()
        this.doBasicData();
      }
    },
    outputDocx() {
      JSZipUtils.getBinaryContent("山东大学软件学院yyyy届就业质量报告.docx", (error, content) => {
        // 山东大学软件学院yyyy届就业质量报告.docx是模板。我们在导出的时候，会根据此模板来导出对应的数据
        // 抛出异常
        if (error) {
          throw error
        }

        // 创建一个JSZip实例，内容为模板的内容
        let zip = new jszip(content);

        // 创建并加载docxtemplater实例对象
        let doc = new docxtemplater().loadZip(zip)

        // 设置模板变量的值
        doc.setData(this.form)

        try {
          // 用模板变量的值替换所有模板变量
          doc.render();
        } catch (error) {
          // 抛出异常
          let e = {
            message: error.message,
            name: error.name,
            stack: error.stack,
            properties: error.properties
          };
          console.log(JSON.stringify({ error: e }));
          throw error;
        }

        // 生成一个代表docxtemplater对象的zip文件（不是一个真实的文件，而是在内存中的表示）
        let out = doc.getZip().generate({
          type: "blob",
          mimeType:
            "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
        });

        // 将目标文件对象保存为目标类型的文件，并命名
        FileSaver.saveAs(out, "山东大学软件学院" + this.form.year + "届就业质量报告.docx");

      });
    },
    toPercent(point) {
      var str = Number(point * 100).toFixed(1);
      str += "%";
      return str;
    },
    doBasicData() {
      getBasicData(this.form.year, this.form.year).then(res => {
        this.total = res.data.total
        this.form.total = res.data.total
        this.form.maleNum = res.data.maleNum
        this.form.femaleNum = res.data.femaleNum
        this.bachelorNum = res.data.bachelorNum
        this.form.bachelorNum = res.data.bachelorNum
        this.masterNum = res.data.masterNum
        this.form.masterNum = res.data.masterNum
        this.form.backToOriginRate = this.toPercent(res.data.backToOriginRate)

        this.doDirectionData();

      })
    },
    doDirectionData() {
      getDirectionData(this.form.year, this.form.year).then(res => {
        console.log(res.data)
        this.employment.work.otherWork.bachelor.num = 0;
        for (let i = 0; i < res.data.bachelor.length; i++) {
          if (res.data.bachelor[i].term == "境内升学") {
            this.employment.study.domestic.bachelor.num = res.data.bachelor[i].num
            this.employment.study.domestic.bachelor.rate = this.toPercent(res.data.bachelor[i].num / this.bachelorNum)
          } else if (res.data.bachelor[i].term == "出国、出境") {
            this.employment.study.aboard.bachelor.num = res.data.bachelor[i].num
            this.employment.study.aboard.bachelor.rate = this.toPercent(res.data.bachelor[i].num / this.bachelorNum)
          } else if (!res.data.bachelor[i].term) {
            this.unemployment.bachelor.num = res.data.bachelor[i].num
            this.unemployment.bachelor.rate = this.toPercent(res.data.bachelor[i].num / this.bachelorNum)
          } else if (res.data.bachelor[i].term == "签就业协议形式就业") {
            this.employment.work.fomalWork.bachelor.num = res.data.bachelor[i].num
          } else if (res.data.bachelor[i].term == "签劳动合同形式就业") {
            this.employment.work.fomalWork.bachelor.num += res.data.bachelor[i].num
            this.employment.work.fomalWork.bachelor.rate = this.toPercent(this.employment.work.fomalWork.bachelor.num / this.bachelorNum)
          } else {
            this.employment.work.otherWork.bachelor.num += res.data.bachelor[i].num
          }
        }
        this.employment.work.otherWork.bachelor.rate = this.toPercent(this.employment.work.otherWork.bachelor.num / this.bachelorNum)

        this.employment.work.otherWork.master.num = 0;
        for (let i = 0; i < res.data.master.length; i++) {
          if (res.data.master[i].term == "境内升学") {
            this.employment.study.domestic.master.num = res.data.master[i].num
            this.employment.study.domestic.master.rate = this.toPercent(res.data.master[i].num / this.masterNum)
          } else if (res.data.master[i].term == "出国、出境") {
            this.employment.study.aboard.master.num = res.data.master[i].num
            this.employment.study.aboard.master.rate = this.toPercent(res.data.master[i].num / this.masterNum)
          } else if (!res.data.master[i].term) {
            this.unemployment.master.num = res.data.master[i].num
            this.unemployment.master.rate = this.toPercent(res.data.master[i].num / this.masterNum)
          } else if (res.data.master[i].term == "签就业协议形式就业") {
            this.employment.work.fomalWork.master.num = res.data.master[i].num
          } else if (res.data.master[i].term == "签劳动合同形式就业") {
            this.employment.work.fomalWork.master.num += res.data.master[i].num
            this.employment.work.fomalWork.master.rate = this.toPercent(this.employment.work.fomalWork.master.num / this.masterNum)
          } else {
            this.employment.work.otherWork.master.num += res.data.master[i].num
          }
        }
        this.employment.work.otherWork.master.rate = this.toPercent(this.employment.work.otherWork.master.num / this.masterNum)

        this.form.BDSNum = this.employment.study.domestic.bachelor.num
        this.form.BDSRate = this.employment.study.domestic.bachelor.rate
        this.form.MDSNum = this.employment.study.domestic.master.num
        this.form.MDSRate = this.employment.study.domestic.master.rate
        this.form.DSNum = this.form.BDSNum + this.form.MDSNum
        this.form.DSRate = this.toPercent(this.form.DSNum / this.total)

        this.form.BASNum = this.employment.study.aboard.bachelor.num
        this.form.BASRate = this.employment.study.aboard.bachelor.rate
        this.form.MASNum = this.employment.study.aboard.master.num
        this.form.MASRate = this.employment.study.aboard.master.rate
        this.form.ASNum = this.form.BASNum + this.form.MASNum
        this.form.ASRate = this.toPercent(this.form.ASNum / this.total)

        this.form.BSNum = this.form.BDSNum + this.form.BASNum
        this.form.BSRate = this.toPercent(this.form.BSNum / this.bachelorNum)
        this.form.MSNum = this.form.MDSNum + this.form.MASNum
        this.form.MSRate = this.toPercent(this.form.MSNum / this.masterNum)
        this.form.SNum = this.form.BSNum + this.form.MSNum
        this.form.SRate = this.toPercent(this.form.SNum / this.total)

        this.form.BFJNum = this.employment.work.fomalWork.bachelor.num
        this.form.BFJRate = this.employment.work.fomalWork.bachelor.rate
        this.form.MFJNum = this.employment.work.fomalWork.master.num
        this.form.MFJRate = this.employment.work.fomalWork.master.rate
        this.form.FJNum = this.form.BFJNum + this.form.MFJNum
        this.form.FJRate = this.toPercent(this.form.FJNum / this.total)

        this.form.BOJNum = this.employment.work.otherWork.bachelor.num
        this.form.BOJRate = this.employment.work.otherWork.bachelor.rate
        this.form.MOJNum = this.employment.work.otherWork.master.num
        this.form.MOJRate = this.employment.work.otherWork.master.rate
        this.form.OJNum = this.form.BOJNum + this.form.MOJNum
        this.form.OJRate = this.toPercent(this.form.OJNum / this.total)

        this.form.BJNum = this.form.BFJNum + this.form.BOJNum
        this.form.BJRate = this.toPercent(this.form.BJNum / this.bachelorNum)
        this.form.MJNum = this.form.MFJNum + this.form.MOJNum
        this.form.MJRate = this.toPercent(this.form.MJNum / this.masterNum)
        this.form.JNum = this.form.FJNum + this.form.OJNum
        this.form.JRate = this.toPercent(this.form.JNum / this.total)

        this.form.BNNum = this.unemployment.bachelor.num
        this.form.BNRate = this.unemployment.bachelor.rate
        this.form.MNNum = this.unemployment.master.num
        this.form.MNRate = this.unemployment.master.rate
        this.form.NNum = this.form.BNNum + this.form.MNNum
        this.form.NRate = this.toPercent(this.form.NNum / this.total)

        this.form.BTNum = this.form.BNNum + this.form.BSNum + this.form.BJNum
        this.form.BTRate = this.toPercent(this.form.BTNum / this.bachelorNum)
        this.form.MTNum = this.form.MNNum + this.form.MSNum + this.form.MJNum
        this.form.MTRate = this.toPercent(this.form.MTNum / this.masterNum)
        this.form.TNum = this.form.NNum + this.form.SNum + this.form.JNum
        this.form.TRate = this.toPercent(this.form.TNum / this.total)

        this.form.bacEmpRate = this.toPercent((this.form.BSNum + this.form.BJNum) / this.bachelorNum)
        this.form.masEmpRate = this.toPercent((this.form.MSNum + this.form.MJNum) / this.masterNum)
        this.form.empRate = this.toPercent((this.form.BSNum + this.form.BJNum + this.form.MSNum + this.form.MJNum) / this.total)

        this.doOrgIndustry()
      }).catch(err => {
        console.log(err)
      })
    },
    count_kind(data) {
      let computer = 0;  //计算机
      let economy = 0;  //金融
      let orgnize = 0;  //管理
      let study = 0;  //科学研究
      let build = 0;  //制造业
      let electric = 0;  //电力
      let educate = 0;  //教育
      let health = 0;  //卫生
      let transport = 0;  //交通运输
      let service = 0;  //服务
      let building = 0;  //房地产
      let culture = 0; //文化
      let army = 0; //军队
      let other = 0;
      let sum = 0
      for (let i in data) {
        let cur = data[i]["term"];
        let num = data[i]["num"];
        if (cur == "信息传输、软件和信息技术服务业") {
          computer += num;
        } else if (cur == "金融业") {
          economy += num;
        } else if (cur == "公共管理、社会保障和社会组织") {
          orgnize += num;
        } else if (cur == "科学研究和技术服务业") {
          study += num;
        } else if (cur == "制造业") {
          build += num;
        } else if (cur == "电力、热力、燃气及水生产和供应业") {
          electric += num;
        } else if (cur == "教育") {
          educate += num;
        } else if (cur == "卫生和社会工作") {
          health += num
        } else if (cur == "交通运输、仓储和邮政业") {
          transport += num;
        } else if (cur == "租赁和商务服务业") {
          health += num
        } else if (cur == "房地产业") {
          building += num
        } else if (cur == "文化、体育和娱乐业") {
          culture += num
        } else if (cur == "军队") {
          army += num;
        } else {
          other += num;
        }
        sum += num;
      }
      // 按照需求排序 big_term term num
      return [
        computer, economy, orgnize, study, build, electric, educate, health, transport, health, building, culture, army, other
      ];
    },
    doOrgIndustry() {
      getOrgIndustryData(this.form.year, this.form.year).then(res => {
        let bachelor = this.count_kind(res.data.bachelor)
        let master = this.count_kind(res.data.master)

        let industrys = ["信息传输、软件和信息技术服务业", "金融业", "公共管理、社会保障和社会组织", "科学研究和技术服务业", "制造业", "电力、热力、燃气及水生产和供应业", "教育"
          , "卫生和社会工作", "交通运输、仓储和邮政业", "租赁和商务服务业", "房地产业", "文化、体育和娱乐业", "军队", "其他"]

        this.form.industry = []
        for (let i = 0; i < industrys.length; i++) {
          let temp = {}
          temp.name = industrys[i]
          temp.bn = bachelor[i]
          temp.br = this.toPercent(bachelor[i] / this.form.BFJNum)
          temp.mn = master[i]
          temp.mr = this.toPercent(master[i] / this.form.MFJNum)
          temp.n = bachelor[i] + master[i]
          temp.r = this.toPercent(temp.n / this.form.FJNum)
          this.form.industry.push(temp)
        }

        let compare = (obj1, obj2) => {
          let val1 = obj1.n
          let val2 = obj2.n
          if (val1 > val2) {
            return -1
          } else if (val1 < val2) {
            return 1
          } else {
            return 0
          }
        }

        this.form.industry = this.form.industry.sort(compare)
        this.form.industryMaxName = this.form.industry[0].name
        this.form.industryMaxRate = this.form.industry[0].r

        this.form.industry2 = this.form.industry[1].name
        this.form.industry3 = this.form.industry[2].name
        this.form.industry4 = this.form.industry[3].name
        this.form.industry5 = this.form.industry[4].name

        this.doOrgName()
      })
    },
    doOrgName() {
      getOrgNameData(this.form.year, this.form.year).then(res => {
        this.form.org = []
        for (let i = 0; i < res.data.length; i++) {
          let temp = res.data[i]
          temp.index = i + 1
          this.form.org.push(temp)
        }

        this.doSchool()
      })
    },
    doSchool() {
      getSchoolData(this.form.year, this.form.year).then(res => {
        this.form.ds1 = res.data.domestic[0].term
        this.form.ds1n = res.data.domestic[0].num
        this.form.ds1r = this.toPercent(res.data.domestic[0].num / this.total)
        this.form.ds2 = res.data.domestic[1].term
        this.form.ds2n = res.data.domestic[1].num
        this.form.ds3 = res.data.domestic[2].term
        this.form.ds3n = res.data.domestic[2].num
        this.form.ds4 = res.data.domestic[3].term
        this.form.ds4n = res.data.domestic[3].num
        this.form.ds5 = res.data.domestic[4].term
        this.form.ds5n = res.data.domestic[4].num
        this.form.ds6 = res.data.domestic[5].term
        this.form.ds6n = res.data.domestic[5].num

        this.form.as1 = res.data.foreign[0].term
        this.form.as1n = res.data.foreign[0].num
        this.form.as1r = this.toPercent(res.data.foreign[0].num / this.total)
        this.form.as2 = res.data.foreign[1].term
        this.form.as2n = res.data.foreign[1].num
        this.form.as3 = res.data.foreign[2].term
        this.form.as3n = res.data.foreign[2].num
        this.form.as4 = res.data.foreign[3].term
        this.form.as4n = res.data.foreign[3].num

        this.doOrgKind()
      })
    },
    count_kind2(data) {
      var com_nation = 0;
      var com_personal = 0;
      var com_three = 0;
      var arm = 0;
      var party = 0;
      var bus_high = 0;
      var bus_tech = 0;
      var bus_mid = 0;
      var bus_other = 0;
      var other = 0;
      var sum = 0;
      for (var i in data) {
        var cur = data[i]["term"];
        var num = data[i]["num"];
        if (cur == "国有企业") {
          com_nation += num;
        } else if (cur == "民营企业") {
          com_personal += num;
        } else if (cur == "三资企业") {
          com_three += num;
        } else if (cur == "部队") {
          arm += num;
        } else if (cur == "党政机关") {
          party += num;
        } else if (cur == "高等教育单位") {
          bus_high += num;
        } else if (cur == "科研设计单位") {
          bus_tech += num;
        } else if (cur == "中初教育单位") {
          bus_mid += num;
        } else if (cur == "其他事业单位") {
          bus_other += num;
        } else {
          other += num;
        }
        sum += num;
      }
      // 针对大类进行计算
      var company = com_nation + com_personal + com_three;
      var bussiness = bus_high + bus_tech + bus_mid + bus_other;

      // 按照需求排序 big_term term num
      return [
        sum,
        party,
        bussiness,
        company,
        arm,
        other,
        bus_high,
        bus_tech,
        bus_mid,
        bus_other,
        com_nation,
        com_personal,
        com_three,
      ];
    },
    doOrgKind() {
      getOrgKindData(this.form.year, this.form.year).then(res => {
        var bachelor = this.count_kind2(res.data.bachelor);
        var master = this.count_kind2(res.data.master);
        var sum = [];
        var bac_percent = [];
        var mas_percent = [];
        var sum_percent = [];
        for (var i in bachelor) {
          sum.push(bachelor[i] + master[i]);
          bac_percent.push(
            ((bachelor[i] / bachelor[0]) * 100).toFixed(1) + "%"
          );
          mas_percent.push(((master[i] / master[0]) * 100).toFixed(1) + "%");
          sum_percent.push(
            (
              ((bachelor[i] + master[i]) / (bachelor[0] + master[0])) *
              100
            ).toFixed(1) + "%"
          );
        }
        var title = [
          "党政机关",
          "事业单位",
          "企业单位",
          "部队",
          "高等教育单位",
          "科研设计单位",
          "中初教育单位",
          "其他事业单位",
          "国有企业",
          "民营企业",
          "三资企业",
          "其他"
        ];
        // 组织数据
        let table = [];
        for (var i = 0; i < 10; i++) {
          var temp = {
            aim: "1",
            item: "1",
            bach_num: "1",
            mas_num: "1",
            sum_num: "1",
            bac_percent: "1",
            mas_percent: "1",
            sum_percent: "1",
          };
          table[i] = temp;
        }

        console.log(table)

        // 党政机关
        table[0].aim = title[0];
        table[0].item = title[0];
        table[0].bach_num = bachelor[1];
        table[0].mas_num = master[1];
        table[0].sum_num = sum[1];
        table[0].bac_percent = bac_percent[1];
        table[0].mas_percent = mas_percent[1];
        table[0].sum_percent = sum_percent[1];
        // 事业单位
        for (var i = 1; i < 5; i++) {
          table[i].aim = title[1];
          table[i].item = title[i + 3];
          table[i].bach_num = bachelor[i + 5];
          table[i].mas_num = master[i + 5];
          table[i].sum_num = sum[i + 5];
          table[i].bac_percent = bac_percent[i + 5];
          table[i].mas_percent = mas_percent[i + 5];
          table[i].sum_percent = sum_percent[i + 5];
        }
        // 企业单位
        for (var i = 5; i < 8; i++) {
          table[i].aim = title[2];
          table[i].item = title[i + 3];
          table[i].bach_num = bachelor[i + 5];
          table[i].mas_num = master[i + 5];
          table[i].sum_num = sum[i + 5];
          table[i].bac_percent = bac_percent[i + 5];
          table[i].mas_percent = mas_percent[i + 5];
          table[i].sum_percent = sum_percent[i + 5];
        }
        // 部队
        table[8].aim = title[3];
        table[8].item = title[3];
        table[8].bach_num = bachelor[4];
        table[8].mas_num = master[4];
        table[8].sum_num = sum[4];
        table[8].bac_percent = bac_percent[4];
        table[8].mas_percent = mas_percent[4];
        table[8].sum_percent = sum_percent[4];

        //其他
        table[9].aim = title[11];
        table[9].item = title[11];
        table[9].bach_num = bachelor[5];
        table[9].mas_num = master[5];
        table[9].sum_num = sum[5];
        table[9].bac_percent = bac_percent[5];
        table[9].mas_percent = mas_percent[5];
        table[9].sum_percent = sum_percent[5];

        this.form.obn = table[9].bach_num
        this.form.obr = table[9].bac_percent
        this.form.omn = table[9].mas_num
        this.form.omr = table[9].mas_percent
        this.form.on = table[9].sum_num
        this.form.or = table[9].sum_percent

        this.form.dzbn = table[0].bach_num
        this.form.dzbr = table[0].bac_percent
        this.form.dzmn = table[0].mas_num
        this.form.dzmr = table[0].mas_percent
        this.form.dzn = table[0].sum_num
        this.form.dzr = table[0].sum_percent

        this.form.sy1bn = table[1].bach_num
        this.form.sy1br = table[1].bac_percent
        this.form.sy1mn = table[1].mas_num
        this.form.sy1mr = table[1].mas_percent
        this.form.sy1n = table[1].sum_num
        this.form.sy1r = table[1].sum_percent

        this.form.sy2bn = table[2].bach_num
        this.form.sy2br = table[2].bac_percent
        this.form.sy2mn = table[2].mas_num
        this.form.sy2mr = table[2].mas_percent
        this.form.sy2n = table[2].sum_num
        this.form.sy2r = table[2].sum_percent

        this.form.sy3bn = table[3].bach_num
        this.form.sy3br = table[3].bac_percent
        this.form.sy3mn = table[3].mas_num
        this.form.sy3mr = table[3].mas_percent
        this.form.sy3n = table[3].sum_num
        this.form.sy3r = table[3].sum_percent

        this.form.sy4bn = table[4].bach_num
        this.form.sy4br = table[4].bac_percent
        this.form.sy4mn = table[4].mas_num
        this.form.sy4mr = table[4].mas_percent
        this.form.sy4n = table[4].sum_num
        this.form.sy4r = table[4].sum_percent

        this.form.qy1bn = table[5].bach_num
        this.form.qy1br = table[5].bac_percent
        this.form.qy1mn = table[5].mas_num
        this.form.qy1mr = table[5].mas_percent
        this.form.qy1n = table[5].sum_num
        this.form.qy1r = table[5].sum_percent

        this.form.qy2bn = table[6].bach_num
        this.form.qy2br = table[6].bac_percent
        this.form.qy2mn = table[6].mas_num
        this.form.qy2mr = table[6].mas_percent
        this.form.qy2n = table[6].sum_num
        this.form.qy2r = table[6].sum_percent

        this.form.qy3bn = table[7].bach_num
        this.form.qy3br = table[7].bac_percent
        this.form.qy3mn = table[7].mas_num
        this.form.qy3mr = table[7].mas_percent
        this.form.qy3n = table[7].sum_num
        this.form.qy3r = table[7].sum_percent

        this.form.bdbn = table[8].bach_num
        this.form.bdbr = table[8].bac_percent
        this.form.bdmn = table[8].mas_num
        this.form.bdmr = table[8].mas_percent
        this.form.bdn = table[8].sum_num
        this.form.bdr = table[8].sum_percent


        this.form.syb = table[1].bach_num + table[2].bach_num + table[3].bach_num + table[4].bach_num
        this.form.sybr = this.toPercent(this.form.syb / this.form.BFJNum)

        this.form.sym = table[1].mas_num + table[2].mas_num + table[3].mas_num + table[4].mas_num
        this.form.symr = this.toPercent(this.form.sym / this.form.MFJNum)

        this.form.sy = this.form.syb + this.form.sym
        this.form.syr = this.toPercent(this.form.sy / this.form.FJNum)

        this.form.qyb = table[5].bach_num + table[6].bach_num + table[7].bach_num
        this.form.qybr = this.toPercent(this.form.qyb / this.form.BFJNum)

        this.form.qym = table[5].mas_num + table[6].mas_num + table[7].mas_num
        this.form.qymr = this.toPercent(this.form.qym / this.form.MFJNum)

        this.form.qy = this.form.qyb + this.form.qym
        this.form.qyr = this.toPercent(this.form.qy / this.form.FJNum)

        console.log(this.form)
       this.outputDocx()

      })
    }
  }
}

</script>